public class TimeTask implements Comparable<TimeTask> {
    long time;
    private Runnable runnable;

    public TimeTask(Runnable runnable, long time) {
        this.runnable = runnable;
        this.time = System.currentTimeMillis() + time;
    }

    public void run() {
        runnable.run();
    }

    public long gettime() {
        return  time;
    }

    @Override
    public int compareTo(TimeTask o) {
        return (int) (this.time - o.time);
    }
}
